package com.zamxie;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.util.StopWatch;

@Slf4j
@SpringBootApplication
public class DemoApplication  extends SpringBootServletInitializer {

    public static void main(String[] args) {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        ConfigurableApplicationContext application =SpringApplication.run(DemoApplication.class,args);
        stopWatch.stop();
        Integer port = application.getBean(ServerProperties.class).getPort();
        log.info("服务启动完成，耗时:{}s，请访问: http://127.0.0.1:{} ", stopWatch.getTotalTimeSeconds(), port);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(DemoApplication.class);
    }

}
